package com.yupi.springbootinit.datasource;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yupi.springbootinit.model.dto.picture.PictureQueryRequest;
import com.yupi.springbootinit.model.entity.Picture;
import com.yupi.springbootinit.service.PictureService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PictureDatasource implements SearchDatasource {

    @Resource
    private PictureService pictureService;
    @Override
    public Page<Picture> search(String searchText, int pageNum, int pageSize) {
        PictureQueryRequest pictureQueryRequest = new PictureQueryRequest();
        pictureQueryRequest.setSearchText(searchText);

        Page<Picture> searchResult = pictureService.search(pictureQueryRequest, pageNum, pageSize);
        return searchResult;
    }
}
